package com.lottery.im.module.result.adapter.result.statistics;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import java.util.List;

public class DoublePkAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
  private int[] colorArr =
      {
          R.color.pk4_fc9030,
          R.color.pk2_5ba9f8,
          R.color.pk3_6a6a6a,
          R.color.pk4_fc9030,
          R.color.pk5_31e3d8,
          R.color.pk10_45e083,
          R.color.pk10_45e083,
          R.color.pk10_45e083,
          R.color.pk10_45e083,
          R.color.pk10_45e083
      };
  private int[] iconArr =
      {
          R.drawable.icon_double_pk_01,
          R.drawable.icon_double_pk_02,
          R.drawable.icon_double_pk_03
      };
  private String[] titleArr =
      { "冠军", "亚军", "季军", "第四名", "第五名", "第六名", "第七名", "第八名", "第九名", "第十名" };

  public DoublePkAdapter(@Nullable List<String> data) {
    super(R.layout.item_double_statistics_pk_list, data);
  }

  @Override protected void convert(final BaseViewHolder helper, String item) {
    TextView mTvTitle = helper.getView(R.id.tv_title);
    mTvTitle.setText(titleArr[helper.getAdapterPosition()]);
    mTvTitle.setBackgroundColor(
        mContext.getResources().getColor(colorArr[helper.getAdapterPosition()]));
    ImageView mIvIcon = helper.getView(R.id.iv_icon);
    TextView mTvName5 = helper.getView(R.id.tv_name5);
    TextView mTvName6 = helper.getView(R.id.tv_name6);
    View mViewName5 = helper.getView(R.id.view_name5);
    View mViewName6 = helper.getView(R.id.view_name6);
    View mViewNum5 = helper.getView(R.id.view_num5);
    View mViewNum6 = helper.getView(R.id.view_num6);

    TextView mTvNum1 = helper.getView(R.id.tv_num1);
    TextView mTvNum2 = helper.getView(R.id.tv_num2);
    TextView mTvNum3 = helper.getView(R.id.tv_num3);
    TextView mTvNum4 = helper.getView(R.id.tv_num4);
    TextView mTvNum5 = helper.getView(R.id.tv_num5);
    TextView mTvNum6 = helper.getView(R.id.tv_num6);
    mIvIcon.setVisibility(View.GONE);
    if (item.contains(",")) {
      String[] str = item.split(",");
      if (helper.getAdapterPosition() < 5) {
        mTvName5.setVisibility(View.VISIBLE);
        mTvName6.setVisibility(View.VISIBLE);
        mTvNum5.setVisibility(View.VISIBLE);
        mTvNum6.setVisibility(View.VISIBLE);
        mViewName5.setVisibility(View.VISIBLE);
        mViewName6.setVisibility(View.VISIBLE);
        mViewNum5.setVisibility(View.VISIBLE);
        mViewNum6.setVisibility(View.VISIBLE);
        if (str.length > 5) {
          mTvNum1.setText(str[0]);
          mTvNum2.setText(str[1]);
          mTvNum3.setText(str[2]);
          mTvNum4.setText(str[3]);
          mTvNum5.setText(str[4]);
          mTvNum6.setText(str[5]);
        }
        if (helper.getAdapterPosition() < 3) {
          mIvIcon.setVisibility(View.VISIBLE);
          mIvIcon.setImageResource(iconArr[helper.getAdapterPosition()]);
        }
      } else {
        mTvName5.setVisibility(View.GONE);
        mTvName6.setVisibility(View.GONE);
        mTvNum5.setVisibility(View.GONE);
        mTvNum6.setVisibility(View.GONE);
        mViewName5.setVisibility(View.GONE);
        mViewName6.setVisibility(View.GONE);
        mViewNum5.setVisibility(View.GONE);
        mViewNum6.setVisibility(View.GONE);
        if (str.length > 3) {
          mTvNum1.setText(str[0]);
          mTvNum2.setText(str[1]);
          mTvNum3.setText(str[2]);
          mTvNum4.setText(str[3]);
        }
      }
    }
  }
}
